#include <cupe.h>

uint32_t tick = 0;

void setup()
{
  cupe_init();
}

void loop()
{
  if (HAL_GetTick() - tick > 2000)
  {
    tick = HAL_GetTick();
    HAL_GPIO_TogglePin(LED_GPIO_PORT, LED_PIN);

    dbLog("Hello, world! %lu\n", tick);
  }

  if (cupe_power_key())
    cupe_shutdown();
}

int main(void)
{
  setup();

  while (1)
  {
    loop();
  }

}

void SysTick_Handler(void)
{
  HAL_IncTick();
}

void NMI_Handler(void)
{
}

void HardFault_Handler(void)
{
  while (1)
  {
  }
}

void MemManage_Handler(void)
{
  while (1)
  {
  }
}

void BusFault_Handler(void)
{
  while (1)
  {
  }
}

void UsageFault_Handler(void)
{
  while (1)
  {
  }
}

void SVC_Handler(void)
{
}

void DebugMon_Handler(void)
{
}

void PendSV_Handler(void)
{
}
